package config

import (
	"log"
	// "shortlink/model"

	"github.com/astaxie/beego/orm"
	_ "github.com/go-sql-driver/mysql"
)

var LinkOrmer orm.Ormer

func InitLinkDb() error {
	dsn := "golang:zxc,./123@tcp(43.139.115.142:3306)/user?charset=utf8mb4&loc=Local&parseTime=true"
	orm.RegisterDriver("mysql", orm.DRMySQL)

	if err := orm.RegisterDataBase("default", "mysql", dsn); err != nil {
		log.Fatal(err)
		return err
	}
	orm.RunSyncdb("default", false, true)

	LinkOrmer = orm.NewOrm()
	return nil
}
